<?php
namespace Home\Model;
use Think\Model;
class UserModel extends Model{
	protected $tableName = "sys_user";
	protected $_validate = array(
		array("user_id", "number", "用户编号只能为数字！",  2, null, self::MODEL_BOTH  ),
		
		array("name", "require", "姓名不能为空！",  self::MUST_VALIDATE, null, self::MODEL_BOTH  ),
//		array("name", '/.*[\u4e00-\u9fa5]+$/', "姓名只能是汉字！",  self::MUST_VALIDATE, "regex", self::MODEL_BOTH  ),
		
		array("user_name", "require", "用户名不能为空！",  self::MUST_VALIDATE, null, self::MODEL_BOTH  ),
		array("user_name", '/^[a-z0-9]*$/', "用户名只能是英文字母或数字的组合！",  self::MUST_VALIDATE, "regex", self::MODEL_BOTH  ),
		array("user_name", '', '用户名已经存在！', 0, 'unique', 1),
		
		array("password", "require", "登录密码不能为空！",  self::MUST_VALIDATE, null, self::MODEL_BOTH  ),
		array("compassword", "password", "登录密码和确认密码必须相同！",  self::MUST_VALIDATE, "confirm", self::MODEL_BOTH  ),
		
		array("email", "require", "Email不能为空！",  self::MUST_VALIDATE, null, self::MODEL_BOTH  ),
		array("email", "email", "Email格式不正确！",  self::MUST_VALIDATE, null, self::MODEL_BOTH  ),
		
		array("dept_id", "require", "所属部门必选！",  self::MUST_VALIDATE, null, self::MODEL_BOTH  ),
		array("dept_id", "number", "部门所选值不合法！",  self::MUST_VALIDATE, null, self::MODEL_BOTH  ),
		
		array("priv_id", "require", "用户角色必选！",  self::MUST_VALIDATE, null, self::MODEL_BOTH  ),
		array("priv_id", "number", "用户所选值不合法！",  self::MUST_VALIDATE, null, self::MODEL_BOTH  ),
		
		array("status", "require", "用户是否在职必选！",  self::MUST_VALIDATE, null, self::MODEL_BOTH  ),
		array("status", array(1,0), "用户在职状态所选值不合法！",  self::MUST_VALIDATE, "in", self::MODEL_BOTH  ),
	);
}
?>